package com.app.reading;

import android.content.Intent;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Main4Activity extends AppCompatActivity {
    TextView txt1,txt2,txt3;
    Button btn_find,btn1_home,btn2_home,btn3_home,btn4_home;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
//        ActionBar actionbar =getSupportActionBar();
//        if(actionbar!=null){
//            actionbar.hide();
//        }
        initView();
    }

    private void initView() {
        txt1=findViewById(R.id.txt1);
        txt2=findViewById(R.id.txt2);
        txt3=findViewById(R.id.txt3);
        btn1_home=findViewById(R.id.btn1_home);
        btn2_home=findViewById(R.id.btn2_home);
        btn3_home=findViewById(R.id.btn3_home);
        btn4_home=findViewById(R.id.btn4_home);
        btn_find=findViewById(R.id.btn_find);
        btn1_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent ch=new Intent();
                ch.setClass(Main4Activity.this,Main5Activity.class);
                startActivity(ch);
            }
        });
        btn2_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent ch=new Intent();
                ch.setClass(Main4Activity.this,Main6Activity.class);
                startActivity(ch);
            }
        });
        btn3_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent ch=new Intent();
                ch.setClass(Main4Activity.this,Main7Activity.class);
                startActivity(ch);
            }
        });
        btn4_home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent ch=new Intent();
                ch.setClass(Main4Activity.this,Main8Activity.class);
                startActivity(ch);
            }
        });
        txt1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                changeFragment(new Fragment1());
            }
        });
        txt2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                changeFragment(new Fragment2());
            }
        });
        txt3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                changeFragment(new Fragment3());
            }
        });
    }
    private void changeFragment(Fragment fragment){
        FragmentManager fm=getSupportFragmentManager();
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(R.id.fl_home,fragment);
        ft.commit();

    }
}
